#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Mikan RDB Module

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_36"
__date__    = "2014/01/05"
__license__ = 'LGPL'

# ------------------------------------------------------------
## Import Section
# ------------------------------------------------------------
# Python
import traceback
import datetime

# ESiPC
from esipc import ESiPCProperty

# Mikan
from mikan.db import AbstractMikanItemDatabase

# ------------------------------------------------------------
## Variable Section
# ------------------------------------------------------------

# ------------------------------------------------------------
## Function Section
# ------------------------------------------------------------

# ------------------------------------------------------------
## Class Section
# ------------------------------------------------------------

# ------------------------------------------------------------
## Mikan DB抽象 クラス
#
class AbstractMikanRDB(AbstractMikanItemDatabase):

	def get_version(self):
		return self.get_db_version()

	def get_name(self):
		return self.get_db_name()

	def get_db_version(self):
		return ""

	def get_db_name(self):
		return ""

	# ----------------------------------------------------
	## Property
	dbversion = ESiPCProperty(get_db_version, None, None)
	dbname = ESiPCProperty(get_db_name, None, None)

# ------------------------------------------------------------
## Mikan DB抽象 クラス
#

# ------------------------------------------------------------
## Mikan DB抽象 クラス
#
def new_mikan_rdb(request, dbtype="sqlite"):
		t = None

		if (dbtype == "sqlite"):
			t = "MikanSqliteRDB"
		if (dbtype == "mysql"):
			t = "MikanMySQLRDB"
		if (dbtype == "postgresql"):
			t = "MikanPostgreSQLRDB"

		try:
			module = "mikan.rdb." + dbtype + "rdb"
			fromlist = [module]
			module = __import__(module, fromlist=fromlist)

			c = getattr(module, t)
			return c(request)
		except:
			print traceback.format_exc()

		return None

# ------------------------------------------------------------
## Main Section
# ------------------------------------------------------------
if __name__ == '__main__':
	pass

# ------------------------------------------------------------
